<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var isPalindrome = function (s) {
        let reg = /[a-z]/;
        let resNum = /[0-9]/;
        const arr = s
          .toLowerCase()
          .split("")
          .filter((item) => {
            if (reg.test(item) || resNum.test(item)) {
              return item;
            }
          });
        // if (arr.length === 1) {
        //     return true
        // }
        for (let i = 0, j = arr.length - 1; i < arr.length && j >= 0; i++, j--) {
          if (arr[i] != arr[j]) {
            return false;
          }
        }
        return true;
      };
      console.log(isPalindrome("0P"));
    </script>
  </body>
</html>
